04. Embedded Terminal Explanation
Embedded Terminal
In this lesson (C++ Intro to Optimization) and the following lesson (C++ Optimization Practice), you'll be using a feature of that classroom that you haven't seen yet.
When you go to the next part of the lesson, an embedded command line tool will load. The command line allows you to execute commands directly to a computer instead of using a mouse and user interface. On Macs and Linux machines, there is a program called Terminal that allows you to type and execute these commands. The equivalent in Windows is the Console Window.
Here is a screenshot of what the embedded command line tool interface looks like:
The following video walks you through how to use the embedded terminal.
Nd113 Embedded Terminal V1
Linux Commands
To learn more about using the command line in the terminal, check out these links:
File Navigation
In the C++ lesson, each demonstration or exercise uses this interface. In the top left corner, you'll find the file browser. Each demo or exercise is contained in its own folder. The name of the folder corresponds with the title of the current lesson section. For example, the next lesson section is called "Demo: Machine Code", and the folder is called "demo_machine_code".
Here is a screenshot of where the file browser is located:
If you double click on a folder, the folder will open. Likewise, double clicking on a file will open the file in a text editor. You can also right-click on a file or folder to download or delete it among other options. The plus sign is used to add new files or folders as well as to upload files or folders.
This next image shows where the text editor is located:
Text Editor
You can edit text files in the text editor. In the C++ exercises, this is where you will be modifying or writing C++ code. The classroom saves your work automatically as you modify files.
Terminal Window
To actually run commands that will compile and execute your C++ programs, you will need to open a terminal window. You click where it says "New Terminal" in the middle bottom of the screen:
And this opens a new terminal window:
The terminal window is where you'll type commands to execute your C++ code. The exercises and demos include instruction files that tell you what commands to type and in what order. So you do not need to learn command line syntax for these lessons.
However, here is an explanation of what those commands do:
cd foldername
cd stands for "change directory". You can use the cd command to change what directory your terminal window is looking at
g++ main.cpp other_files.cpp
This command compiles your C++ program. Sometimes you'll also see a command like:
g++ -std=c++11 main.cpp other_files.cpp
This command tells the compiler to use the C++11 standard. By default the compiler uses C++98. C++11 contains a handful of features that C++98 does not contain. So whenever a program uses a feature of C++11, you need to tell the compiler.
The last command you'll see in these lessons is
./a.out
When you compile your programs, the compiler outputs a file called a.out.
Executing ./a.out
on the command line will run your program.
If you'd like to learn more about the basics of terminal commands, here is a link to an introductory article: terminal commands.
Menu
The embedded command line interface also has a menu in the bottom left corner.
If you click on the menu, you'll see two options:
REFRESH WORKSPACE will restart the workspace. It will not erase your work.
However, RESET DATA will restart the workspace AND replace all of your files with the original workspace files. You will lose all of your work including any extra files you created in the workspace.